﻿using System;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows;
using System.ComponentModel;

namespace CheckLift.UI.Controls
{
    public delegate void KeyDownSpecific(object sender, EventArgs e);
    /// <summary>
    /// Interaction logic for myTexBox.xaml
    /// </summary>    
    [ContentProperty("ContentText")]
    public partial class myTextBox : UserControl
    {
        public event KeyDownSpecific KeyDownSpecific;
       
        public myTextBox()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty BodyTextProperty = DependencyProperty.Register("ContentText", typeof(string), typeof(myTextBox), new FrameworkPropertyMetadata("ContentText"));

        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.R && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                if (KeyDownSpecific != null)
                    KeyDownSpecific(sender, new EventArgs());
            }            
        }

        public string BodyText 
        {
            get 
            { 
                return this.myTextCtrl.Text; 
            }
            set 
            {
                this.myTextCtrl.Text = value;                 
            }
        }


        public string ContentText 
        {
            get
            {
                return (string)GetValue(BodyTextProperty);
            }
            set
            {
                SetValue(BodyTextProperty, value);                
            }
        }

        protected override void OnContentChanged(object oldContent, object newContent)
        {
            //base.OnContentChanged(oldContent, newContent);
        }
    }
}
